
<header>
  <ul class="nav navbar-nav navbar-right" id="login_reg_car">
  </ul>
  <a href="##" id="wodd">我的</a>
  <a href=""><span class="glyphicon glyphicon-phone-alt "></span>联系客服</a><br>
  <div class="row">
    <div class="col-md-3"><h1>NBA球迷商城</h1></div>
    <div class="col-md-6">
      <form class="navbar-form navbar-left" id="ft1">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <a type="submit" class="btn glyphicon glyphicon-search" ></a>
      </form>
    </div>
    <div class="col-md-3"><h4><span><a href="">定制球衣</a></span><span><a href="">定制T恤</a></span></h4></div>
  </div>
</header>
<div>
  <nav class="navbar navbar-inverse navbar-static-top logoIcon">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex8-collapse">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <div class="collapse navbar-collapse navbar-ex8-collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="/users/souye">Home</a></li>
          <li><a href="/users/shangcheng">商城</a></li>
          <li><a href="http://localhost:8000">互动社区</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
        </ul>
      </div><!-- /.navbar-collapse -->
    </div>
  </nav>
</div>
<template>
  <tr data-id="{id}">
    <td>
      <img src="/uploads/{imgsrc}">
    </td>
    <td class="name">{name}</td>
    <td class="price">{price}</td>
    <td class="num">{num}</td>
    <td class="xiaoji">{xiaoji}</td>
    <td>
      <span class="del">删除</span>
    </td>
  </tr>
</template>



<script>
  function check_login() {
    $.getJSON('/users/user_session', function (flag) {
      $('#login_reg_car').empty();
      if (flag) {
        $('#login_reg_car').append('<li class="cart_link"><a href="/users/ce">' +
          '购物车<span id="shop_num" class="badge"></span></a></li><li><a href="##">' +
          '欢迎你：' + flag.username + '</a></li><li class="logout"><a href="##" >注销</a></li>');
        // $.getJSON('/users/get_number?zh=' + flag.zh, function (num) {
        //   $('#shop_num').html(num);
        // });
      } else {
        $('#login_reg_car').append('<li class="login"><a  href="denglu">登录</a></li>' +
          '<li><a  href="zhuce">注册</a></li>')
      }
    });
  }
  check_login()
</script>
<script>
  $('#login_reg_car').on('click', 'li', function () {
    if (this.className == 'logout') {
      $.getJSON('/users/logout', function (flag) {
        if (flag) {
          alert("已注销");
          check_login()
        }
      })
    }
  })
  $('#wodd').click(function () {
    alert('ok')
    $.getJSON('/users/geren', function (flag) {
      switch (flag) {
        case 1:
          location.href = 'http://localhost:1337/users/ge';
          break;
        case 2:
          alert('请登录后再试');
          break;
      }
    })
  })
</script>
